package com.tpay.client.presenter;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.HasUiHandlers;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.NameToken;
import com.gwtplatform.mvp.client.annotations.NoGatekeeper;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.proxy.Place;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.PlaceRequest;
import com.gwtplatform.mvp.client.proxy.Proxy;
import com.gwtplatform.mvp.client.proxy.RevealRootContentEvent;
import com.smartgwt.client.util.SC;
import com.tpay.client.CurrentUser;
import com.tpay.client.NameTokens;
import com.tpay.client.event.LoginAuthenticatedEvent;
import com.tpay.client.uihandlers.ErrorPageUiHandlers;
import com.tpay.shared.action.LoginAction;
import com.tpay.shared.action.LoginResult;

public class ErrorPagePresenter extends Presenter<ErrorPagePresenter.MyView, ErrorPagePresenter.MyProxy> implements ErrorPageUiHandlers {
	@ProxyCodeSplit
	@NameToken(NameTokens.errorPage)
	@NoGatekeeper
	public interface MyProxy extends Proxy<ErrorPagePresenter>, Place {
	}
	
	public interface MyView extends View, HasUiHandlers<ErrorPageUiHandlers> {
		
	}

	private final PlaceManager placeManager;
	
	@Inject
	public ErrorPagePresenter(EventBus eventBus, MyView view, MyProxy proxy, PlaceManager placeManager) {
		super(eventBus, view, proxy);

		this.placeManager = placeManager;
		
		this.getView().setUiHandlers(this);
	}

	@Override
	protected void revealInParent() {
		RevealRootContentEvent.fire(this, this);
	}

	@Override
	public void onOkButtonClicked() {
		SC.say("mainPage로 이동");
		PlaceRequest request = new PlaceRequest(NameTokens.mainPage);
		placeManager.revealPlace(request);
	} 
}
